home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / language / embedded / m68k / cc68k.arc / LIST.C < prev    next >
C/C++ Source or Header  |  1986-10-26  |  5KB  |  151 lines

  1. #include        "stdio.h"
  2. #include        "string.h"
  3. #include        "c.h"
  4. #include        "expr.h"
  5. #include        "gen.h"
  6. #include        "cglbdec.h"
  7.  
  8. /*
  9.  *    68000 C compiler
  10.  *
  11.  *    Copyright 1984, 1985, 1986 Matthew Brandt.
  12.  *  all commercial rights reserved.
  13.  *
  14.  *    This compiler is intended as an instructive tool for personal use. Any
  15.  *    use for profit without the written consent of the author is prohibited.
  16.  *
  17.  *    This compiler may be distributed freely for non-commercial use as long
  18.  *    as this notice stays intact. Please forward any enhancements or questions
  19.  *    to:
  20.  *
  21.  *        Matthew Brandt
  22.  *        Box 920337
  23.  *        Norcross, Ga 30092
  24.  */
  25.  
  26.  put_sc(scl)
  27. int     scl;
  28. {       switch(scl) {
  29.                 case sc_static:
  30.                         fprintf(list,"Static      ");
  31.                         break;
  32.                 case sc_auto:
  33.                         fprintf(list,"Auto        ");
  34.                         break;
  35.                 case sc_global:
  36.                         fprintf(list,"Global      ");
  37.                         break;
  38.                 case sc_external:
  39.                         fprintf(list,"External    ");
  40.                         break;
  41.                 case sc_type:
  42.                         fprintf(list,"Type        ");
  43.                         break;
  44.                 case sc_const:
  45.                         fprintf(list,"Constant    ");
  46.                         break;
  47.                 case sc_member:
  48.                         fprintf(list,"Member      ");
  49.                         break;
  50.                 case sc_label:
  51.                         fprintf(list,"Label");
  52.                         break;
  53.                 case sc_ulabel:
  54.                         fprintf(list,"Undefined label");
  55.                         break;
  56.                 }
  57. }
  58.  
  59.  put_ty(tp)
  60. TYP     *tp;
  61. {       if(tp == 0)
  62.                 return;
  63.         switch(tp->type) {
  64.                 case bt_char:
  65.                         fprintf(list,"Char");
  66.                         break;
  67.                 case bt_short:
  68.                         fprintf(list,"Short");
  69.                         break;
  70.                 case bt_enum:
  71.                         fprintf(list,"enum ");
  72.                         goto ucont;
  73.                 case bt_long:
  74.                         fprintf(list,"Long");
  75.                         break;
  76.                 case bt_unsigned:
  77.                         fprintf(list,"unsigned long");
  78.                         break;
  79.                 case bt_float:
  80.                         fprintf(list,"Float");
  81.                         break;
  82.                 case bt_double:
  83.                         fprintf(list,"Double");
  84.                         break;
  85.                 case bt_pointer:
  86.                         if( tp->val_flag == 0)
  87.                                 fprintf(list,"Pointer to ");
  88.                         else
  89.                                 fprintf(list,"Array of ");
  90.                         put_ty(tp->btp);
  91.                         break;
  92.                 case bt_union:
  93.                         fprintf(list,"union ");
  94.                         goto ucont;
  95.                 case bt_struct:
  96.                         fprintf(list,"struct ");
  97. ucont:                  if(tp->sname == 0)
  98.                                 fprintf(list,"<no name> ");
  99.                         else
  100.                                 fprintf(list,"%s ",tp->sname);
  101.                         break;
  102.                 case bt_ifunc:
  103.                 case bt_func:
  104.                         fprintf(list,"Function returning ");
  105.                         put_ty(tp->btp);
  106.                         break;
  107.                 }
  108. }
  109.  
  110.  list_var(sp,i)
  111. SYM     *sp;
  112. int     i;
  113. {       int     j;
  114.     char    su[80];
  115.         for(j = i; j; --j)
  116.                 fprintf(list,"    ");
  117.         fprintf(list,"%-10s =%06x ",sp->name,sp->value.u);
  118.         if( sp->storage_class == sc_external)
  119.         {
  120.                 strcpy(su,sp->name);
  121.                 upcase(su);        /* Convert to upper case */
  122.                 fprintf(output,"\tXREF\t%s\n",su);
  123.     }
  124.         else if( sp->storage_class == sc_global )
  125.         {
  126.                 strcpy(su,sp->name);
  127.                 upcase(su);        /* convert to upper case */
  128.                 fprintf(output,"\tXDEF\t%s\n",su);
  129.         }
  130.         put_sc(sp->storage_class);
  131.         put_ty(sp->tp);
  132.         fprintf(list,"\n");
  133.         if(sp->tp == 0)
  134.                 return;
  135.         if((sp->tp->type == bt_struct || sp->tp->type == bt_union) &&
  136.                 sp->storage_class == sc_type)
  137.                 list_table(&(sp->tp->lst),i+1);
  138. }
  139.  
  140.  list_table(t,i)
  141. TABLE   *t;
  142. int     i;
  143. {       SYM     *sp;
  144.         sp = t->head;
  145.         while(sp != NULL) {
  146.                 list_var(sp,i);
  147.                 sp = sp->next;
  148.                 }
  149. }
  150.  
  151.